/**
 *
 */
package com.ybkj.daijia.server.service.impl;

import com.ybkj.daijia.server.mapper.NoticeXPassengerMapper;
import com.ybkj.daijia.server.model.NoticeXPassenger;
import com.ybkj.daijia.server.service.NoticeXPassengerService;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author Shine
 *
 */
@Service
public class DefaultNoticeXPassengerService implements NoticeXPassengerService {


    @Autowired
    private NoticeXPassengerMapper noticeXPassengerMapper;


    @Transactional(rollbackFor = Exception.class)
    public NoticeXPassenger save(NoticeXPassenger noticeXPassenger) {

        noticeXPassengerMapper.insertRecord(noticeXPassenger);

        return noticeXPassenger;
    }

    @Override
    public NoticeXPassenger findOne(Long id) {

        return noticeXPassengerMapper.selectByPrimaryKey(id);

    }


    @Transactional(rollbackFor = Exception.class)
    public void delete(Long id) {

        noticeXPassengerMapper.deleteByPrimaryKey(id);

    }

    @Override
    public NoticeXPassenger findByPassengerAndNotice(Long passengerId, Long noticeId) {

        return noticeXPassengerMapper.selectByPassengerAndNotice(passengerId, noticeId);

    }

    @Transactional(rollbackFor = Exception.class)
    public void updateHasRead(Long id) {

        noticeXPassengerMapper.updateHasRead(id);

    }

    @Override
    public List<Long> selectNotReadNoticeIds(Long passengerId) {
        return noticeXPassengerMapper.selectNotReadNoticeIds(passengerId);
    }


}